package com.jiazhong.Servlet;

import com.jiazhong.Service.GoodsService;
import com.jiazhong.Service.Impl.GoodsServiceImpl;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/goods/delGoodsById.do")
public class DelGoodsServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //获得客户端发送的请求数据
        int goods_id = Integer.parseInt(request.getParameter("goods_id"));
        System.out.println(goods_id);
        //调用GoodsService中关于删除商品的方法
        GoodsService goodsService=new GoodsServiceImpl();
        goodsService.delGoodsById(goods_id);
        //根据结果跳转到展示页面
        response.sendRedirect("/goods/queryGoods.do");
    }
}
